<!---->
<!--  AAChartView.html-->
<!--  AAChartKit-Swift-->
<!---->
<!--  Created by An An  on 17/4/19.-->
<!--  Copyright © 2017年 An An . All rights reserved.-->
<!--*************** ...... SOURCE CODE ...... ***************-->
<!--***...................................................***-->
<!--***  https://github.com/AAChartModel/AAChartKit       ***-->
<!--***  https://github.com/AAChartModel/AAChartKit-Swift ***-->
<!--***...................................................***-->
<!--*************** ...... SOURCE CODE ...... ***************-->

<!--/*-->
<!---->
<!--* --------------------------------------------------------------------------------->
<!--*  🌕 🌖 🌗 🌘  ❀❀❀   WARM TIPS!!!   ❀❀❀ 🌑 🌒 🌓 🌔-->
<!--*-->
<!--* Please contact me on GitHub,if there are any problems encountered in use.-->
<!--* GitHub Issues : https://github.com/AAChartModel/AAChartKit-Swift/issues-->
<!--* --------------------------------------------------------------------------------->
<!--* And if you want to contribute for this project, please contact me as well-->
<!--* GitHub        : https://github.com/AAChartModel-->
<!--* StackOverflow : https://stackoverflow.com/users/7842508/codeforu-->
<!--* JianShu       : http://www.jianshu.com/u/f1e6753d4254-->
<!--* SegmentFault  : https://segmentfault.com/u/huanghunbieguan-->
<!--*-->
<!--* --------------------------------------------------------------------------------->
<!---->
<!--*/-->


<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=3.0,user-scalable = no">
            <title>AAChartKit-Swift</title>
            
            <script src="AAHighchartsLib.js">
                </script>
            <script src="AAHighchartsMore.js">
                </script>
<!--            <script src="AAHighcharts-3d.js">-->
<!--                </script>-->
            <script src="AAFunnel.js">
                </script>
            <script src="AAOptionsConstructor.js">
                </script>
            <!--            <script src = "https://img.hcharts.cn/highcharts/themes/dark-unica.js">-->
            <!--                </script>-->
            
            <!--    若介意本地js代码体积(250KB左右)过大，可换用加载网络js代码 -->
            <!--            <script src="https://img.hcharts.cn/highcharts/highcharts.js">-->
            <!--                </script>-->
            <!--            <script src="https://img.hcharts.cn/highcharts/highcharts-more.js">-->
            <!--                </script>-->
            
            <style>
                *{
                    -webkit-user-select: none;
                    user-select: none;
                }
            </style>
            
            </head>
    <body>
        <div id="container" style="width:min-450px; height: 200px; margin: -8px">
        </div>
        <script >
            
        var AAGlobalChart;
            
        function loadTheHighChartView (
                                      sender,
                                      receivedWidth,
                                      receivedHeight
                                      ) {
             var AAOptions = configureAAOptions (
                                               sender,
                                               receivedWidth,
                                               receivedHeight
                                               );
                                               
            var animationEasingType = AAOptions.plotOptions.series.animation.easing;
            if (animationEasingType) { //懒调用(只有在 AAChartModel 实例对象设置了 animationType 属性值的时候才会调用设置动画类型的函数,否则不调用)
                AAOptions.plotOptions.series.animation.easing = configureTheChartAnimationEasingType(animationEasingType);
            }
            AAOptions.credits = {enabled:false};//去掉表格右下角版权信息

            AAGlobalChart = Highcharts.chart('container', AAOptions);
           //全局配置(可通过全局配置设置主题)https://api.hcharts.cn/highcharts#Highcharts.setOptions
        };
        
        function onlyRefreshTheChartDataWithSeries (receivedSeries) {
            var receivedSeriesElementArr = JSON.parse(receivedSeries);
            
            for (var i = 0; i < receivedSeriesElementArr.length; i++) {
                var receivedSeriesData = receivedSeriesElementArr[i].data;
                // 获取series
                var chartSeries =  AAGlobalChart.series[i];
                // 执行只刷新数据的函数
                chartSeries.setData(receivedSeriesData);
            }
        }
        
        function chartSeriesContentHideOrShow (hidden) {
            for (var i = 0; i < AAGlobalChart.series.length; i++) {
                var series = AAGlobalChart.series[i];
                if (hidden == true) {
                    series.hide();
                } else {
                    series.show();
                }
            }
        }
        
        function showTheSeriesElementContentWithIndex (elementIndex) {
            var series = AAGlobalChart.series[elementIndex];
            series.show();
        }
        
        function configureTheChartAnimationEasingType (easingType) {
        var animationObject =  {
                easeInQuad: function(pos) {
                    return Math.pow(pos, 2);
                },
                
                easeOutQuad: function(pos) {
                    return -(Math.pow((pos-1), 2) -1);
                },
                
                easeInOutQuad: function(pos) {
                    if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,2);
                    return -0.5 * ((pos-=2)*pos - 2);
                },
                
                easeInCubic: function(pos) {
                    return Math.pow(pos, 3);
                },
                
                easeOutCubic: function(pos) {
                    return (Math.pow((pos-1), 3) +1);
                },
                
                easeInOutCubic: function(pos) {
                    if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,3);
                    return 0.5 * (Math.pow((pos-2),3) + 2);
                },
                
                easeInQuart: function(pos) {
                    return Math.pow(pos, 4);
                },
                
                easeOutQuart: function(pos) {
                    return -(Math.pow((pos-1), 4) -1);
                },
                
                easeInOutQuart: function(pos) {
                    if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,4);
                    return -0.5 * ((pos-=2)*Math.pow(pos,3) - 2);
                },
                
                easeInQuint: function(pos) {
                    return Math.pow(pos, 5);
                },
                
                easeOutQuint: function(pos) {
                    return (Math.pow((pos-1), 5) +1);
                },
                
                easeInOutQuint: function(pos) {
                    if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,5);
                    return 0.5 * (Math.pow((pos-2),5) + 2);
                },
                
                easeInSine: function(pos) {
                    return -Math.cos(pos * (Math.PI/2)) + 1;
                },
                
                easeOutSine: function(pos) {
                    return Math.sin(pos * (Math.PI/2));
                },
                
                easeInOutSine: function(pos) {
                    return (-0.5 * (Math.cos(Math.PI*pos) -1));
                },
                
                easeInExpo: function(pos) {
                    return (pos===0) ? 0 : Math.pow(2, 10 * (pos - 1));
                },
                
                easeOutExpo: function(pos) {
                    return (pos===1) ? 1 : -Math.pow(2, -10 * pos) + 1;
                },
                
                easeInOutExpo: function(pos) {
                    if(pos===0) return 0;
                    if(pos===1) return 1;
                    if((pos/=0.5) < 1) return 0.5 * Math.pow(2,10 * (pos-1));
                    return 0.5 * (-Math.pow(2, -10 * --pos) + 2);
                },
                
                easeInCirc: function(pos) {
                    return -(Math.sqrt(1 - (pos*pos)) - 1);
                },
                
                easeOutCirc: function(pos) {
                    return Math.sqrt(1 - Math.pow((pos-1), 2));
                },
                
                easeInOutCirc: function(pos) {
                    if((pos/=0.5) < 1) return -0.5 * (Math.sqrt(1 - pos*pos) - 1);
                    return 0.5 * (Math.sqrt(1 - (pos-=2)*pos) + 1);
                },
                
                easeOutBounce: function(pos) {
                    if ((pos) < (1/2.75)) {
                        return (7.5625*pos*pos);
                    } else if (pos < (2/2.75)) {
                        return (7.5625*(pos-=(1.5/2.75))*pos + 0.75);
                    } else if (pos < (2.5/2.75)) {
                        return (7.5625*(pos-=(2.25/2.75))*pos + 0.9375);
                    } else {
                        return (7.5625*(pos-=(2.625/2.75))*pos + 0.984375);
                    }
                },
                
                easeInBack: function(pos) {
                    var s = 1.70158;
                    return (pos)*pos*((s+1)*pos - s);
                },
                
                easeOutBack: function(pos) {
                    var s = 1.70158;
                    return (pos=pos-1)*pos*((s+1)*pos + s) + 1;
                },
                
                easeInOutBack: function(pos) {
                    var s = 1.70158;
                    if((pos/=0.5) < 1) return 0.5*(pos*pos*(((s*=(1.525))+1)*pos -s));
                    return 0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos +s) +2);
                },
                
                elastic: function(pos) {
                    return -1 * Math.pow(4,-8*pos) * Math.sin((pos*6-1)*(2*Math.PI)/2) + 1;
                },
                
                swingFromTo: function(pos) {
                    var s = 1.70158;
                    return ((pos/=0.5) < 1) ? 0.5*(pos*pos*(((s*=(1.525))+1)*pos - s)) :
                    0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos + s) + 2);
                },
                
                swingFrom: function(pos) {
                    var s = 1.70158;
                    return pos*pos*((s+1)*pos - s);
                },
                
                swingTo: function(pos) {
                    var s = 1.70158;
                    return (pos-=1)*pos*((s+1)*pos + s) + 1;
                },
                
                bounce: function(pos) {
                    if (pos < (1/2.75)) {
                        return (7.5625*pos*pos);
                    } else if (pos < (2/2.75)) {
                        return (7.5625*(pos-=(1.5/2.75))*pos + 0.75);
                    } else if (pos < (2.5/2.75)) {
                        return (7.5625*(pos-=(2.25/2.75))*pos + 0.9375);
                    } else {
                        return (7.5625*(pos-=(2.625/2.75))*pos + 0.984375);
                    }
                },
                
                bouncePast: function(pos) {
                    if (pos < (1/2.75)) {
                        return (7.5625*pos*pos);
                    } else if (pos < (2/2.75)) {
                        return 2 - (7.5625*(pos-=(1.5/2.75))*pos + 0.75);
                    } else if (pos < (2.5/2.75)) {
                        return 2 - (7.5625*(pos-=(2.25/2.75))*pos + 0.9375);
                    } else {
                        return 2 - (7.5625*(pos-=(2.625/2.75))*pos + 0.984375);
                    }
                },
                
                easeFromTo: function(pos) {
                    if ((pos/=0.5) < 1) return 0.5*Math.pow(pos,4);
                    return -0.5 * ((pos-=2)*Math.pow(pos,3) - 2);
                },
                
                easeFrom: function(pos) {
                    return Math.pow(pos,4);
                },
                
                easeTo: function(pos) {
                    return Math.pow(pos,0.25);
                }
            }
        
        return animationObject[easingType];
        }
        
        //pragma mark -- setter method 适应内容https://code.hcharts.cn/highcharts/4YM0a8
        function setTheChartViewContentWidth (receivedWidth) {
            var container = document.getElementById('container');//获得元素
            container.style.width = receivedWidth;//设置宽度
            AAGlobalChart.reflow();
        }
        
        function setTheChartViewContentHeight (receivedHeight) {
            var container = document.getElementById('container');//获得元素
            container.style.height = receivedHeight;//设置高度
            AAGlobalChart.reflow();
        }
        
            </script>
    </body>
</html>
